///
/// The state controlling game play. This state handles all game logic,
/// such as moving the balls and allowing the player to move.
///

#pragma once

// Dependencies
#include "GameState.h"
#include "Ball.h"
#include <vector>
#include "Vector"
#include "MenuItem.h"

namespace Core { class Game; }

namespace GameStates
{
    
    class PlayGameState : public Core::GameState
    {
    // Structors
    public:
        PlayGameState(Core::Game &game);
        
    public:
        void Start();
        bool Update();
        void End();
        
    private:
        void NewGame();
        void HandleCollisions();
		void CollisionFunction2();
		void AddBall();
		void FindWallCollision (Ball& ball);
		double CalculateScore();
		void CalculateRotation(const Ball& iter);
		Math::Vector2d FindSlope(Math::Vector2d vec1, Math::Vector2d vec2);
		
    private:
        enum GameMode { Playing, FallingBalls };
        GameMode gameMode;
        
        hgeSprite* BackgroundSprite;
        hgeSprite* BallSprite;
        hgeSprite* PlayerBallSprite;
        hgeSprite* cursor;
        hgeSprite* playAgainButton, *quitButton;
        std::vector<Ball> BallHolder;
		std::vector<Ball> CollidedBalls;
		HEFFECT BallCollisionEffect;
		HEFFECT WallCollisionEffect;
        Ball playerBall;
        unsigned long timeUntilNextBall, timeStart, timeEnd;
        HWND windowHandle;
        hgeFont* gameFont;
        double delta;
		double score;
		double rotationPos;
		double rotationVel;
		const double rectRight, rectLeft, rectTop, rectBottom, center, epsilon, gamma;
		
        std::vector<MenuItem> menuItems;
    };
    
}